home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 4 / MacMania 4.toast / / Sound / SoundEffects 0.9.2 / SoundEffects Developer’s Kit / Interfaces / ModGetSetSamples.c < prev    next >
C/C++ Source or Header  |  1994-11-19  |  837b  |  33 lines

  1. #include "ModGetSetSamples.h"
  2.  
  3.  
  4. signed long GetSample16(Ptr samplePtr, short bps)
  5. {
  6.     signed long    mySample;
  7.     short        byte, numBytes, sampleSize;
  8.     
  9.     sampleSize = bps/8 + (bps%8 != 0);
  10.     numBytes = (sampleSize < sizeof(long)) ? sampleSize : sizeof(long);
  11.     
  12.     for (byte = 0; byte < numBytes; byte++)
  13.         *(unsigned char *)((long)&mySample+byte) = *(unsigned char *)(samplePtr+byte);
  14.     
  15.     mySample = mySample >> (sizeof(long)-numBytes) * 8;
  16.     
  17.     return mySample;
  18. }
  19.  
  20.  
  21. void SetSample16(Ptr samplePtr, signed long mySample, short bps)
  22. {
  23.     Ptr        myPtr;
  24.     short    byte, numBytes, sampleSize;
  25.     
  26.     sampleSize = bps/8 + (bps%8 != 0);
  27.     numBytes = (sampleSize < sizeof(long)) ? sampleSize : sizeof(long);
  28.     
  29.     myPtr = samplePtr;
  30.     
  31.     for (byte = sizeof(long)-numBytes; byte < sizeof(long); byte++)
  32.         *(unsigned char *)myPtr++ = *(unsigned char *)((long)&mySample+byte);
  33. }